Test Series - java script

Test Number 41/92

Q: Cookies were originally designed for __________
A. Client-side programming
B. Server-side programming
C. Both Client-side & Server-side programming
D. Web programming
Solution: Cookies are data, stored in small text files, on your computer. Cookies were originally designed for server-side programming, and at the lowest level, they are implemented as an extension to the HTTP protocol.
Q: The Cookie manipulation is done using which property?
A. cookie
B. cookies
C. manipulate
D. modify
Solution: The cookie property sets or returns all name/value pairs of cookies in the current document. There are no methods involved: cookies are queried, set, and deleted by reading and writing the cookie property of the Document object using specially formatted strings.
Q: Which of the following explains Cookies nature?
A. Non Volatile
B. Volatile
C. Intransient
D. Transient
Solution: Cookies are transient by default; the values they store last for the duration of the web browser session but are lost when the user exits the browser. When a web server has sent a web page to a browser, the connection is shut down, and the server forgets everything about the user.
Q: Which attribute is used to extend the lifetime of a cookie?
A. higher-age
B. increase-age
C. max-age
D. lifetime
Solution: If you want a cookie to last beyond a single browsing session, you must tell the browser how long (in seconds) you would like it to retain the cookie by specifying a max-age attribute. A number of seconds until the cookie expires. A zero or negative number will expire the cookie immediately.
Q: Which of the following defines the Cookie visibility?
A. domain Path
B. local & session storage
C. server storage
D. transient Path
Solution: sessionStorage, localStorage and Cookies all are used to store data on the client-side. Each one has its own storage and expiration limit. Cookie visibility is scoped by document origin as localStorage and sessionStorage are, and also by document path.
Q: Which of the following can be used to configure the scope of the Cookie visibility?
A. path
B. domain
C. both path and domain
D. server
Solution: The Cookie visibility scope is configurable through cookie attributes path and domain. Domain attribute in the cookie is used to specify the domain for which the cookie is sent.path includes the Path attribute in the cookie to specify the path for which this cookie is sent.
Q: How can you set a Cookie visibility scope to localStorage?
A. /
B. %
C. %
D. //
Solution: Setting the path of a cookie to “/” gives scoping like that of localStorage and also specifies that the browser must transmit the cookie name and value to the server whenever it requests any web page on the site.
Q: Which of the following is a boolean cookie attribute?
A. bool
B. secure
C. lookup
D. domain
Solution: The final cookie attribute is a boolean attribute named secure that specifies how cookie values are transmitted over the network. By default, cookies are insecure, which means that they are transmitted over a normal, insecure HTTP connection. If a cookie is marked secure, however, it is transmitted only when the browser and server are connected via HTTPS or another secure protocol.
Q: Which of the following function is used as a consequence of not including semicolons, commas or whitespace in the Cookie value?
A. encodeURIComponent()
B. encodeURI()
C. encodeComponent()
D. encode()
Solution: Cookie values cannot include semicolons, commas, or whitespace. For this reason, you may want to use the core JavaScript global function encodeURIComponent() to encode the value before storing it in the cookie.
Q: What is the constraint on the data per cookie?
A. 2 KB
B. 1 KB
C. 4 KB
D. 3 KB
Solution: Each cookie can hold up to only 4 KB. In practice, browsers allow many more than 300 cookies total, but the 4 KB size limit may still be enforced by some. Whereas storage of session is around a minimum of 5mb.

You Have Score    /10